feat(core): filter sessions by path and add setting to disable#24849
Conversation
Upstream commits: - fix: clear timeout after promise rejection (anomalyco#24864) - chore: generate - fix(bash): memory leak - release parsed syntax trees (anomalyco#24861) - feat(core): filter sessions by path and add setting to disable (anomalyco#24849) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> # Conflicts: # packages/core/CLAUDE.md # packages/core/src/util/CLAUDE.md
|
This breaks the previous behavior and causes Your disable option kills the filtering entirely, which is even worse for users tripping over the above, and it leaves no way to restore the previous behavior. The prior behavior should have started as the default moving forward from this PR else all users will run into the above issue. |
|
Now sessions from subdirectories are appearing in the parent directory, which is very bad and incompatible. I think it's a bug. |
I submitted #31210 which should restore the behavior for cases outside of what this PR intended to address (it did so too broadly and roped in non-git cases). @jlongster please review #31210 as it refines the scope of your earlier PR - it's led to a string of issues and even cases where users may continue a session context from within its parent folder, which can lead to edits outside of the intended |
将 upstream/dev (38adc13) 合并到 dev-custom,解决 14 个文件的合并冲突, 同时修复因上游模块迁移导致的构建错误。构建与 Smoke Test 全部通过。 ## 上游主要更新 - **HttpApi 后端重构与完整测试覆盖**:authorization middleware、instance context、 workspace routing、websocket proxy、SDK parity、Effect HttpApi backend parity。 - **桌面端修复**:路径匹配导致 sessions 丢失、强 ID、现有数据修复 (anomalyco#25013)。 - **模型支持**:新增 Mistral Medium 3.5 with reasoning (anomalyco#24996)。 - **参数调整**:Azure/DeepSeek 默认参数优化;系统提示词顺序调整为 Global → Project → Skills。 - **Session 路径**:新增按路径过滤 session 及禁用设置 (anomalyco#24849);数据库新增 session_path、 icon_url_override 字段。 - **TUI 体验**:粘贴摘要开关更易用 (anomalyco#24869)。 - **内存泄漏修复**:Bash 工具释放解析后的语法树 (anomalyco#24861)。 - **MCP 健壮性**:无效 MCP URL 处理修复 (anomalyco#25019)。 - **核心模块迁移**:global、filesystem、flag、log、npm、effect 等大量底层模块从 packages/opencode 迁移到 packages/core,建立更清晰的分层。 - **版本同步**:v1.14.30。 ## 本地定制功能保全 以下本地特有功能在合并中完全保全,未受上游更新影响: - **StrategyLoops 轻量框架**:StrategyLoops/ 目录下 PEE/MPEE 模块、Role/Session 管理、 opencode 适配器等全部保留。 - **可配置存储路径**:database、log、worktree、snapshot 路径支持环境变量与配置文件自定义。 - **日志系统增强**:log-tee 模式(同时输出到文件与控制台)、可配置日志目录。 - **Snapshot 优化**:使用本地 ignore 库替代 git check-ignore,避免 Windows ENAMETOOLONG; 文件夹级忽略的批量删除逻辑完整保留。 - **MCP 面板项目名提示**:status-popover-body.tsx 中当前项目名展示保留。 - **设置页路径展示**:settings-general.tsx 中 worktree/snapshot/config 路径加载与展示保留。 - **分叉版本构建工作流**、中文贡献文档、定制 i18n 键等全部保留。 ## 冲突解决与代码整合 | 文件 | 冲突处理策略 | |------|-------------| | dialog-edit-project.tsx | 采用上游提取的 getProjectAvatarSource() 函数,同时保留本地 override/url/color 完整逻辑 | | sidebar-items.tsx / layout.tsx | 整合上游头像来源逻辑,保留本地 icon override 与 color 判定 | | settings-general.tsx | 保留本地 loadConfigFiles / loadWorktreeInfo / loadSnapshotInfo 及路径展示 UI;合并上游新增的 shell / displayBackend 等逻辑 | | status-popover-body.tsx | 保留本地 projectName 提示;去除上游删除的废弃 load 状态 | | config/config.ts | 采纳上游 Schema 修正(ConfigAgent.Info 替换 AgentRef;MCP 禁用配置改用 Schema.Struct) | | server/event.ts | 保留本地 ConfigUpdated 事件定义,同时合并上游 Schema 化改造 | | server/routes/global.ts | 完整保留本地特有的 /storage/* 与 /config/path 路由;合并上游模块导入路径重构 | | snapshot/index.ts | 修正导入路径到 @opencode-ai/core/*,保留本地 ignore 库、StorageConfig、Flag 等全部定制 | | worktree/index.ts | 同上,修正模块路径,保留本地 StorageConfig / Flag / resolveDir 等定制 | ## 构建修复(模块迁移适配) 上游将 global、flag 等模块迁移到 packages/core 后,本地定制代码出现模块解析失败: 1. **StorageConfig 跨包迁移**:将 storage-config.ts 从 opencode 包迁移到 packages/core/src/storage/storage-config.ts,原位置改为重新导出;解除 core → opencode 的反向依赖,避免循环依赖。 2. **依赖补充**:core/package.json 新增 jsonc-parser 依赖(原仅在 opencode 中声明)。 3. **导入路径修正**:core/src/util/log.ts、snapshot/index.ts、worktree/index.ts 中的 ../global、../flag/flag、../storage/storage-config 等相对路径统一修正为 @opencode-ai/core/* 路径。
Previously, we tracked the absolute path for each session. The session list endpoint happens to accept
directoryto filter on, and this conflicted with the global SDKdirectoryparam. We just happened to be filtering by directory because the SDK sends that parameter for all requests.This is a feature we want to support though: for people in big monorepos it's useful to filter sessions by the directory you opened in. However, we can't use the absolute path: the sessions might be in a git worktree or remote workspace with a different absolute path, but the relative path should be the same. So we started tracking the relative path in the
pathfield, and this PR changes the filtering to filter based on thatYou can now optionally disable this so you always get all sessions for the project regardless of where you opened OpenCode
Previous sessions will not have
pathset; in this case we will still fallback to the same filtering as beforeType of change
What does this PR do?
Adds directory-aware filtering for TUI session lists while preserving existing session list API behavior. The session list endpoint now supports explicit project-wide listing and project-relative path filtering, including a fallback for older sessions with
path = NULL.The TUI now scopes sessions to the current directory by default, with a command menu toggle to disable directory scoping and list all sessions for the project.
How did you verify your code works?
bun test test/server/session-list.test.tsbun test test/cli/cmd/tui/sync.test.tsxbun typecheckbun turbo typecheckScreenshots / recordings
Not included.
Checklist